#!/bin/sh /etc/rc.common
# Copyright (C) 2008-2022 OpenWrt.org

START=99

PROG=/usr/bin/pppwn

start() {
	config_load "pppwn"
	
	config_get "port" "config" "port"
	config_get "fwver" "config" "fwver"
	
	local enable
	config_get_bool enable config enable 0
	
	[ "${enable}" -gt 0 ] || return

	$PROG --interface $port --fw $fwver --stage1 "/etc/pppwn/stage1.bin" --stage2 "/etc/pppwn/stage2.bin" -a > /var/log/pppwn.log &

}

stop() {
    ps -w | grep -v "grep" | grep "$PROG" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
    echo "" > /var/log/pppwn.log
}